//****************************************************************************//
//
// Softimage XSI / Mental Ray muhHair Hair shader
//
// by Daniel "thebigMuh" Rind, Drakon Rider
//
// Version 1.06, 21.10.2007
//
//****************************************************************************//

//*********//
// HISTORY //
//*********//
Version 1.06, 21.10.2007 by Drakon Rider
 - Some more performance fixes after profiling.
 - Added ASM_SSE define that can switch off all asm inlines for compiling
   for 64bit systems with compilers with no support for asm inlines.
 - Added type miVector4 in muhHair.h with 4th dummy member for internal vector
   calculations with 128 bit memory transfer commands instead of slow and 
   sometimes strange cache misses maskmovdqu instruction with 96 bits memory
   transfer using miVector type.

Version 1.05, 09.10.2007 by Drakon Rider
 - Most of 3d vector functions are rewritten with SSE commands. Executable was 
   compiled with Intel C++ 8.0.

Version 1.04, 07.10.2007 by Drakon Rider
 - Proper fix of memory leak has been done with help of Benr from xsibase 
   forum. Render speed is now no more affected by dynamic memory allocation in
   shader.

Version 1.03, 07.10.2007 by Drakon Rider
 - Fixed memory leak in a simple, but slow way. Memory allocation and 
   releasing must be throwed away from main shader subroutine for better
   render speed. This memory leak possibly mostly affects rendering with
   transparecy enabled and caused XSI (mentalray) to crash after some time
   or rendering with an error of not enough memory.

Version 1.02, 06.10.2007 by Drakon Rider
 - Some inlines for RGBA color processing were rewritten using SSE.
   Main speedup is still do not use transparency. That possibly caused
   a recursive shader call and about hafling render speed because main
   shader looks like very fast already. There still some places for 
   asm/SSE optimisation left. For building with VC 6.0 shader.lib from XSI SDK
   4 (4.2) required. Do not links properly with shader.lib from XSI SDK 6.5.

Version 1.01, 06.07.2004
 - Fixed a stupid bug that caused more rays to be traced than necessary
 - Fixed a tiny bug involving detail shadows
 - Replaced cos and acos calls with lookup tables. If, against all odds, you 
   get banding, please tell me. Lookup tables are 1023 entries big, so you 
   should not get banding under normal lighting conditions.
Version 1.00, 04.07.2004
 - Initial release

//**************//
// WHAT THIS IS //
//**************//

It's a hair geometry shader for XSI 4.0 / mental ray 3.3.

No, not for 3.5. Don't ask for it, please.

//**************//
// INSTALLATION //
//**************//

Please use the enclosed muhHair.xsiaddon file to install the muhHair shader. 
Should something go wrong, you can still use the SPDL file.

//*******//
// USAGE //
//*******//

It's a hair shader, and meant to be used on hair geometry _only_. You will very
likely get odd results if you don't use it on hair geometry. The shader also
does not support the volume mode of XSI's hair primitive (yet).

The documentation is, as usual, in the doc subdirectory. This shader has
a lot of options, so please take the time and read through the docs once or twice.
Should still something go wrong, my contact info is at the end of this file.

//************//
// THE SOURCE //
//************//

The complete C source to the shader is enclosed in the "source" subdirectory,
along with a VC 6 project. You are free to do with it whatever you want, but 
should you manage to produce something usefull/interesting/nice/cool with it, 
please be so kind and give me credit. Of course, if you find any "unintentional 
features", please e-mail me so I can fix it.

//*********//
// CREDITS //
//*********//

Puh. First of all thanks to all the good people who worked on this paper:
http://graphics.stanford.edu/papers/hair/
I omitted a lot of the things they suggest in the paper, but a few of the base
ideas remain.

More thanks go to the people working with XSI hair and putting up with the 
considerable render times hair has. Hopefully my shader can help a bit.

I am a 23 years old computer science student from Vienna/Austria. I love computer
graphics (which is the field I am studying in), I love XSI, and I love Mental 
Ray, so starting to program for it was only natural ;-).

If you want to contact me, you can do so at:

thebigMuh@chello.at

or by lurking for my presence on the XSI Base (www.xsibase.com) or the
3rd-Dimension (www.3rd-d.co.uk) internet boards, and maybe even occasionally
CG Talk (www.cgtalk.com).

Eventually I might even update my homepage (www.animusartis.com).